<template>
  <van-nav-bar
    :title="title"
    left-text="返回"
    left-arrow
    @click-left="onClickLeft"
  >
  </van-nav-bar>
  <van-cell-group>
    <van-cell is-link v-for="item in list" :key="item.id" @click="todtile(item)">
      <template #title>
        {{item.name}}
      </template>
    </van-cell>
  </van-cell-group>
  
</template>

<script setup>
import { useRoute, useRouter } from "vue-router";
import { reactive, ref, onMounted } from "vue";
import { getemrlist } from "../api/emr";
const router = useRouter();
const route = useRoute()

const selectitem = JSON.parse(localStorage.getItem("selectitem"));
const title = selectitem.name + selectitem.age + "岁";
function onClickLeft() {
  //返回上一页
  router.back();
}
const list = ref([]);
getemrlist({
  id: selectitem.id,
  sortid:route.params.id
}).then((res) => {
  if (res.code == 0) {
    list.value = res.data;
  } else {
    this.$toast.fail(res.msg);
  }
});
function todtile(item) {
  router.push({
    name: 'emrdata',
    params: {
      id: item.id,
      sortid: route.params.id,
      name: item.name.split(' ')[0]
    }
  });
}
</script>

<style></style>
